package com.dwxt.cdms.controller;

import com.dwxt.cdms.base.Page;
import com.dwxt.cdms.entity.YouthHope;
import com.dwxt.cdms.service.YouthHopeService;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.text.ParseException;

@RestController
@RequestMapping({ "/cdms/witheart" })
public class YouthHopeController {

    @Autowired
    private YouthHopeService youthHopeService;

    /**
     * @Description: 接收心晓数据
     * @param youthHope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/receiveData")
    public BaseResult receiveData(@RequestBody YouthHope youthHope) throws ParseException, IOException {
        return youthHopeService.receiveData(youthHope);
    }

    /**
     * @Description: PC端列表查询
     * @param page:
     * @param name:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/30
     */
    @RequestMapping("/selectYoutHopePageGroup")
    public BaseResult selectYoutHopePageGroup(Page page, String name){
        return youthHopeService.selectYoutHopePageGroup(page,name);
    }

    /**
     * @Description: PC端单个用户睡眠记录查询
     * @param page:
     * @param customerId:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/30
     */
    @RequestMapping("/selectYoutHopePage")
    public BaseResult selectYoutHopePage(Page page,@RequestParam(required = true, name = "customerId") Integer customerId){
        return youthHopeService.selectYoutHopePage(page,customerId);
    }

    /**
     * @Description: 通过id查询单条数据
     * @param id:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectYoutHopeById")
    public BaseResult selectYoutHopeById(Integer id){
        return youthHopeService.selectYoutHopeById(id);
    }

    /**
     * @Description: 通过客户id和时间查询
     * @param customerId:
    * @param dayTime:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectYoutHopeByCustomerIdAndTime")
    public BaseResult selectYoutHopeByCustomerIdAndTime(Integer customerId,String dayTime){
        return youthHopeService.selectYoutHopeByCustomerIdAndTime(customerId, dayTime);
    }
}
